#pragma once

#include "panda_resolver.hpp"
#include "panda_uv_helper.hpp"
#include "uv.h"
#include <list>
#include <vector>
#include <string>

namespace PandaImpl{
class ThreadImpl;
class ResolverImpl : public Panda::Resolver {
  friend class UVHelper;
 public:
  explicit ResolverImpl(ThreadImpl* thread);
  bool SyncResolver(const char* url, Panda::OnResolve on_resolver);
  int AsyncResolver(const char* url, char* ips[], int max_size);

 private:
  void OnResolverCb(uv_getaddrinfo_t* req, int status, addrinfo* res);
  ThreadImpl* thread_;
  struct ResolverContext
  {
    uv_getaddrinfo_t req;
    std::string url;
    std::vector<std::string> ip;
    Panda::OnResolve on_resolver;
    struct addrinfo addr_info;
  };
  std::list<ResolverContext> resolver_info;
};
}  // namespace PandaImpl